//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.baidu.trace.b;

import com.baidu.trace.a;
import java.io.IOException;
import java.io.InputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public final class k implements b {
    private DatagramSocket a = null;
    private DatagramPacket b = null;
    private InetAddress c = null;
    private int d = 8300;

    private k(int var1) {
        this.d = var1;
    }

    protected static k a(int var0) {
        return new k(var0);
    }

    public final void a(e var1) {
        try {
            this.a = new DatagramSocket(this.d);
            this.c = InetAddress.getByName("gateway.yingyan.baidu.com");
            this.b = new DatagramPacket((byte[])null, 0, this.c, 8300);
        } catch (IOException var2) {
            a.a("udp socket connect failed");
        }
    }

    public final void a() {
        try {
            this.b = null;
            this.c = null;
            if(this.a != null && !this.a.isClosed()) {
                this.a.close();
            }

            return;
        } catch (Exception var4) {
            ;
        } finally {
            this.a = null;
        }

    }

    public final boolean b() {
        return true;
    }

    public final int c() {
        return this.d;
    }

    public final void a(byte[] var1) throws IOException {
        if(this.b == null) {
            this.b = new DatagramPacket(var1, var1.length, this.c, 8300);
        } else {
            this.b.setData(var1);
            this.b.setLength(var1.length);
        }

        this.a.send(this.b);
    }

    public final InputStream d() throws IOException {
        return null;
    }
}
